<html>
	<head>
		<title>String_score</title>
		<script src="string_score.js"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
		<script> 
			var abrv = "";
			var fuzzines = 0;
			var sortable = [];
		
			function sort_score(a,b)
			{
				b.score = b.name.score(abrv,fuzzines);
				a.score = a.name.score(abrv,fuzzines);
				return b.score - a.score;
			}
		
			function print_sort(arr,remove)
			{
				var list = $("ol");
				list.html("");
				$.each(sortable, function(i,v) {
					if(!remove || (remove && v.score > 0))
					{
						list.append("<li>" + v.name + ", " + v.score +"</li>" );
					}
				});
			}
			
			function arrayfy(selector, arr) {
				$(selector).children().each(function(){
					arr.push( {name: $(this).html() ,score: 0});
				});
			}
			
			$(function(){
			
				arrayfy("ol",sortable);
				print_sort(sortable);
				$("#abrv").keyup(function(){
					abrv = $(this).val();
					fuzzines = $("#fuzzines").val();
					sortable.sort(sort_score);
					print_sort(sortable,$("#remove").is(':checked'));
				});
			});
		</script>
	</head>
	<body>
		<h2>How to add itens?</h2>
		<p>Go to the index.html and add more <code>< li >'s</code></p>
	
		<label for="abrv">Abbreviation: </label>
		<input name="abrv" id="abrv" />
		<label for="fuzzines">Fuzzines: (0 - 1)</label>
		<input value="0" id="fuzzines" />
		<label for="remove">Remove zero-values? </label>
		<input type="checkbox" name="remove" id="remove" />
		<ol>
			<li>Hello</li>
			<li>Hi</li>
			<li>Hello World</li>
			<li>Hi from Brazil</li>
			<li>wxy</li>
			<li>xwz</li>
		</ol>
	</body>
</html>